home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / comm / ward165.zip / WARD165.EXE / ProcessZip.cpp < prev    next >
C/C++ Source or Header  |  1996-07-14  |  1KB  |  67 lines

  1. // ProcessZip.cpp
  2. // Simple CONSOLE program to process incoming .zip
  3. // files for War FTP Daemon
  4. //
  5. // This is a C++ source code file. If you want to modify
  6. // the ProcessZip.exe program you must have a C++ 
  7. // compiler. You can not run this file from the
  8. // command line.
  9. // You can however use Process.Zip.exe as that file
  10. // is the compiled version of this file.
  11.  
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <sys/types.h>
  15. #include <sys/stat.h>
  16. #include <process.h>
  17. #include <string.h>
  18.  
  19. char *FileName;
  20. struct _stat st;
  21.  
  22. main(int argc, char **argv)
  23. {
  24.     int iRval;
  25.     int Pause = 0;
  26.  
  27.     if (argc < 2)
  28.         return -1; // Missing filename
  29.     --argc;
  30.  
  31.     FileName = *++argv;
  32.  
  33.     if (_stat(FileName,&st))
  34.         return -2; // File does not exuist
  35.  
  36.     if ((iRval = _spawnlp(_P_WAIT,"unzip.exe","unzip.exe","-tqq",FileName,NULL)) == -1)
  37.         return -3; // Failed to start unzip
  38.  
  39.     if (iRval)
  40.         return iRval; // Error code returned from unzip
  41.  
  42.     // Archive is OK. If we have command line arguments, try to extract the file(s)
  43.  
  44.     while(--argc > 0)
  45.     {
  46.         ++argv;
  47.         if (!strcmp(*argv,"-p"))
  48.         {
  49.             ++Pause;
  50.             continue;
  51.         }
  52.  
  53.         fprintf(stderr,"War: Trying to extract '%s'\n", *argv);
  54.         
  55.         // If the file exits, it will not be extracted.
  56.         if(_spawnlp(_P_WAIT,"unzip.exe","unzip.exe","-Cqqn", FileName,*argv,NULL) == 0)
  57.             break; // We have the file
  58.     }
  59.  
  60.     if (Pause)
  61.     {
  62.         fprintf(stderr,"Press ENTER to continue...");
  63.         getc(stdin);
  64.     }
  65.     return 0; // Archive is OK
  66. }
  67.